<template>
    <article>
        <h1 class="t_nav"><router-link to="/blog/home" class="n1">网站首页</router-link><router-link to="/blog/articlelist" class="n2">文章列表</router-link></h1>
        <div class="bloglist left">
            <div v-for="data in tableData">
                <article-item :article-id=data.id>
                    <span slot="title">{{data.title}}</span>
                    <span slot='created_at'>{{data['created_at']}}</span>
                    <span slot="user">{{data.username}}</span> {{data.body.substr(0,100)}}
                </article-item>
            </div>
    
        </div>
        <aside-right></aside-right>
        <el-col :span="24"
                class="toolbar"
                style="margin-top:20px;">
            <el-pagination layout="prev, pager, next"
                           :page-size="pagesize"
                           :total="total"
                           :current-page="currentpage"
                           @current-change="pageHandle">
            </el-pagination>
        </el-col>
    </article>
</template>
<script>
import article_item from './article_item.vue'
import aside_right from './aside_right.vue'
export default {
    components: {
        'article-item': article_item,
        'aside-right': aside_right,
    },
    data() {
        return {
            username: 'JimCreen',
            tableData: [],
            currentpage:1,
            total:1,
            pagesize:1
        }
    },
    created() {
        api.getData('api/article', this);
    },
    methods: {
        pageHandle(val) {
            api.getDataByPage('api/article', val, this);
        }
    }
}
</script>
<style lang="scss">
h1.t_nav span {
    float: right;
    color: #999
}

h1.t_nav {
    border-bottom: #F1F1F1 1px solid;
    font-size: 12px;
    font-weight: normal;
    line-height: 40px;
    height: 40px;
}

h1.t_nav a {
    width: 100px;
    display: block;
    text-align: center;
    color: #fff;
    float: left
}

.n1 {
    background: #5EA51B;
}

.n2 {
    background: #8BBF5D;
}
</style>